package cn.itcast.shop.category.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.itcast.shop.category.vo.Category;

public class CategoryDao extends HibernateDaoSupport {

	public List<Category> findAll() {
		String hql="from Category ";
		@SuppressWarnings("unchecked")
		List<Category> list=this.getHibernateTemplate().find(hql);
		return list;
	}

	/**
	 * 修改一级分类
	 * @param category
	 */
	public void save(Category category) {
		this.getHibernateTemplate().save(category);
	}

	/**
	 * DAO层根据cid查询一级分类的方法
	 * @param cid
	 * @return
	 */
	public Category findByCid(Integer cid) {
		return this.getHibernateTemplate().get(Category.class, cid);
	}
	
	/**
	 * DAO层的删除一级分类的方法
	 * @param category
	 */
	public void delete(Category category) {
		this.getHibernateTemplate().delete(category);
	}

	public void update(Category category) {
		this.getHibernateTemplate().update(category);
	}

	
	
}
































